<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	public function _initModulesFrontController(){
		$front=Zend_Controller_Front::getInstance();
		$front->setControllerDirectory(array(
			'default'=>'./application/controllers',
			'admin'=>'./application/modules/admin'
		));
	}
	
	protected function _initMainLayout(){
		Zend_Layout::startMvc();
		$layout=Zend_Layout::getMvcInstance();
		$layout->setLayout('main');
	}
	
	
	
	protected function _initDoctype(){
		$this->bootstrap('view');
		$view=$this->getResource('view');
		$view->doctype('XHTML1_STRICT');
	}
	
	protected function _initAutoLoader(){
		$autoloader = Zend_Loader_Autoloader::getInstance();
		$autoloader->registerNamespace('Txy_');
	}
	
	protected function _initRouter(){
		$frontController=Zend_Controller_Front::getInstance();
		$router=$frontController->getRouter();
		$route = new Zend_Controller_Router_Route_Regex(
		    'wenzhang/(.+)-aid(\d+)\.html',
		    array(
		        'controller' => 'wenzhang',
		        'action'     => 'content'
		    ),
		    array(
		        1 => 'description',
		        2 => 'id'
		    ),
		    'wenzhang/%s-aid%d.html'
		);
		
		$routeP = new Zend_Controller_Router_Route_Regex(
		    'shangpin/(.+)-pid(\d+)\.html',
		    array(
		        'controller' => 'shangpin',
		        'action'     => 'content'
		    ),
		    array(
		        1 => 'description',
		        2 => 'id'
		    ),
		    'shangpin/%s-pid%d.html'
		);
		
		$routeJG = new Zend_Controller_Router_Route_Regex(
		    'shangpin/(.+)-jid(\d+)\.html',
		    array(
		        'controller' => 'shangpin',
		        'action'     => 'price-chart'
		    ),
		    array(
		        1 => 'description',
		        2 => 'id'
		    ),
		    'shangpin/%s-jid%d.html'
		);
		
		$routeG = new Zend_Controller_Router_Route_Regex(
		    'gallery/(.+)-gid(\d+)\.html',
		    array(
		        'controller' => 'gallery',
		        'action'     => 'content'
		    ),
		    array(
		        1 => 'description',
		        2 => 'id'
		    ),
		    'gallery/%s-gid%d.html'
		);
		
		$routeCJG = new Zend_Controller_Router_Route_Regex(
		    'cai-jia-ge/(.+)-cid(\d+)\.html',
		    array(
		        'controller' => 'cai-jia-ge',
		        'action'     => 'page'
		    ),
		    array(
		        1 => 'description',
		        2 => 'id'
		    ),
		    'cai-jia-ge/%s-cid%d.html'
		);
		
		$routeS = new Zend_Controller_Router_Route_Regex(
		    'shop/(.+)\.html',
		    array(
		        'controller' => 'shop',
		        'action'     => 'content'
		    ),
		    array(
		        1 => 'url',
		    ),
		    'shop/%s.html'
		);
		
		$routeSS = new Zend_Controller_Router_Route(
		    'shop/search/:url/:page',
		    array(
		        'controller' => 'shop',
		        'action'     => 'search',
		        'page'=>1
		    )
		);
		
		$routeSST = new Zend_Controller_Router_Route(
		    'shop/search/:url/tag/:tags/:page',
		    array(
		        'controller' => 'shop',
		        'action'     => 'search',
		        'page'=>1
		    )
		);
		
		$routeZ = new Zend_Controller_Router_Route_Regex(
		    'zhuanti/(.+)-zid(\d+)\.html',
		    array(
		        'controller' => 'zhuanti',
		        'action'     => 'content'
		    ),
		    array(
		        1 => 'description',
		        2 => 'id'
		    ),
		    'zhuanti/%s-zid%d.html'
		);
		
		$routeNL = new Zend_Controller_Router_Route(
	    	'wenzhang/newslist/:page',
	    	array('controller' => 'wenzhang', 'action' => 'list','content_type'=>'0','page'=>1)
			);
		$routeDL = new Zend_Controller_Router_Route(
	    	'wenzhang/digestlist/:page',
	    	array('controller' => 'wenzhang', 'action' => 'list','content_type'=>'1','page'=>1)
			);
		$routeKL = new Zend_Controller_Router_Route(
	    	'wenzhang/knowledgelist/:page',
	    	array('controller' => 'wenzhang', 'action' => 'list','content_type'=>'2','page'=>1)
			);
		$routeHPL=new Zend_Controller_Router_Route(
			'shangpin/hotlist/:page',
			array('controller'=>'shangpin','action'=>'list','itemlisttype'=>'0','page'=>1)
			);
		$routeNPL=new Zend_Controller_Router_Route(
			'shangpin/newlist/:page',
			array('controller'=>'shangpin','action'=>'list','itemlisttype'=>'1','page'=>1)
			);
		$routePPL=new Zend_Controller_Router_Route(
			'shangpin/promotionlist/:page',
			array('controller'=>'shangpin','action'=>'list','itemlisttype'=>'2','page'=>1)
			);
			
/*		$routeSpTag=new Zend_Controller_Router_Route(
		    'shangpin/tag/:tags',
			array('controller'=>'shangpin','action'=>'tag')
		);*/
		$routeSpTagPages=new Zend_Controller_Router_Route(
		    'shangpin/tag/:tags/:page',
			array('controller'=>'shangpin','action'=>'tag','page'=>1)
		);
		
		$routeWb = new Zend_Controller_Router_Route_Regex(
		    'weibo/(\d+)\.html',
		    array(
		        'controller' => 'weibo',
		        'action'     => 'single-page'
		    ),
		    array(
		        1=> 'id'
		    ),
		    'weibo/%d.html'
		);
		
		$router->addRoute('articlecontent', $route);
		$router->addRoute('productcontent', $routeP);
		$router->addRoute('productprice', $routeJG);
		$router->addRoute('gallerycontent', $routeG);
		$router->addRoute('caijiagecontent', $routeCJG);
		$router->addRoute('shopcontent', $routeS);
		$router->addRoute('shopsearch', $routeSS);
		$router->addRoute('shopsearchtag', $routeSST);
		$router->addRoute('zhuanticontent', $routeZ);
		$router->addRoute('newslist', $routeNL);
		$router->addRoute('digestlist', $routeDL);
		$router->addRoute('knowledgelist', $routeKL);
		$router->addRoute('hotproduces',$routeHPL);
		$router->addRoute('newproduces',$routeNPL);
		$router->addRoute('promotionproduces',$routePPL);
		//$router->addRoute('spTag',$routeSpTag);
		$router->addRoute('spTagPage',$routeSpTagPages);
		$router->addRoute('weiboPage',$routeWb);
	}
	
	protected function _initAcl(){
		$frontcontroller=Zend_Controller_Front::getInstance();
		$frontcontroller->registerPlugin(new Txy_Extends_PluginAcl());
	}

}

